#ifndef __MEMORY_POOL_H_
#define __MEMORY_POOL_H_

#include "container/list.h"

// 空闲节点结构体
struct free_node_t {
    char *data;
	struct list_head entry;
};

// 内存块结构体
struct mem_block_t{
    struct free_node_t *nodes;
	struct list_head   entry;
};
struct memory_pool_t
{
    struct list_head    free_node_head;
    struct list_head    mem_block_head;
    int data_size;
	int object_count;
};

struct memory_pool_t *memory_pool_create(int data_size, int object_count);
void  memory_pool_destroy(struct memory_pool_t *pool);
void* memory_pool_malloc(struct memory_pool_t *pool);
void  memory_pool_free(struct memory_pool_t *pool, void *data);

#endif // __MEMORY_POOL_H_